import { createRouter, createWebHashHistory } from "vue-router";
import { useAuthStore } from "@/stores/auth";
import frame_routes from "@/router/frame"
import login_routes from "@/router/login"

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: frame_routes.concat(login_routes)
});

router.beforeEach((to, from) => {
  //全局导航守卫，判断是否登录
  const authStore = useAuthStore();
  if (!authStore.is_login && to.name != "login") {
    return { name: "login" };
  }
});

export default router;
